<template>
  <ul class="detailbottom">
    <li class="bottomtop" @click.stop="selectAllMusic">
      <div class="icon"></div>
      <div class="title">播放全部</div>
    </li>
    <li v-for="value in playlist" :key='value.id' class="item" @click.stop="selectMusic(value.id)">
      <h3>{{value.name}}</h3>
      <p>{{value.al.name}}-{{value.ar[0].name}}</p>
    </li>
  </ul>
</template>

<script>
import { mapActions } from 'vuex'
export default {
  name: 'DetailBottom',
  data () {
    return {}
  },
  props: {
    playlist: {
      type: Array,
      default: () => [],
      required: true
    }
  },
  methods: {
    ...mapActions([
      'setFullPlayer',
      'setMiniPlayer',
      'getSongs',
      'setCurrentIndex'
    ]),
    selectMusic (id) {
      this.getSongs(id)
      this.setFullPlayer(true)
      this.setMiniPlayer(false)
    },
    selectAllMusic () {
      const ids = []
      this.setFullPlayer(true)
      this.setMiniPlayer(false)
      this.playlist.forEach(function (value) {
        ids.push(value.id)
      })
      this.setCurrentIndex(0)
      this.getSongs(ids)
    }
  }
}
</script>

<style scoped lang='scss'>
  @import '../../assets/css/variable.scss';
  @import '../../assets/css/mixin.scss';
  .detailbottom{
    position: relative;
    z-index: 999;
    li{
      width: 100%;
      height: 100px;
      padding: 20px;
      box-sizing: border-box;
      border-bottom: 1px solid #ccc;
      @include bg_sub_color();
    }
    .bottomtop{
      display: flex;
      align-items: center;
      border-top-left-radius: 50px;
      border-top-right-radius: 50px;
      .icon{
        width: 60px;
        height: 60px;
        @include bg_img('../../assets/images/small_play');
      }
      .title{
        margin-left: 20px;
        @include font_color();
        @include font_size($font_large);
      }
    }
    .item{
      h3{
        @include no-wrap();
        @include font_color();
        @include font_size($font_medium);
      }
      p{
        @include font_color();
        @include font_size($font_samll);
        opacity: .8;
      }
    }
  }
</style>
